package com.zb.baidumap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zb.baidumap.acts.BaseActivity;
import com.zb.baidumap.acts.FirstMapActivity;
import com.zb.baidumap.adapters.MainListAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {

    private RecyclerView recyclerView;
    private MainListAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        recyclerView = findViewById(R.id.recycler_view);
        adapter = new MainListAdapter();
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        initData();
        initListener();
    }

    private void initListener() {
        adapter.setOnItemClickedListener(new MainListAdapter.OnItemClickListener() {
            @Override
            public void onItemClicked(View v, int position) {
                Intent i = new Intent(MainActivity.this, classData.get(position));
                startActivity(i);
            }
        });
    }

    private List<String> data = new ArrayList<>();
    private List<Class<? extends BaseActivity>> classData = new ArrayList<>();


    private void initData() {
        List<String> data = new ArrayList<>();
        data.add("初始百度地图");





        classData.add(FirstMapActivity.class);
        adapter.setData(data);
    }


}